﻿using System;
using System.Collections.Generic;
using System.Text;
using NUnit.Framework;
using PassBag.Logic;

namespace TestPassBag {
    [TestFixture, Description ("Test the find item in password list")]
    public class TestPasswordObjectListFind {

        [Test, Description ("Test the find item in password list")]
        public void TestFindList () {
            PasswordObjectComparer comparer = new PasswordObjectComparer ();
            List<PasswordObject> passwordObjectList = new List<PasswordObject> ();

            Guid guid1 = new Guid ("{CA761232-ED42-11CE-BACD-00AA0057B223}");
            Guid guid2 = new Guid ("{CA761232-ED42-11CE-BACD-00AA0057B224}");
            Guid guid3 = new Guid ("{DA761232-ED42-11CE-BACD-00AA0057B223}");
            Guid guid4 = new Guid ("{EA761232-ED42-11CE-BACD-00AA0057B223}");

            passwordObjectList.Add (new PasswordObject (guid3));
            passwordObjectList.Add (new PasswordObject (guid2));
            passwordObjectList.Add (new PasswordObject (guid4));
            passwordObjectList.Add (new PasswordObject (guid1));


            // Set comparaison method to DisplayName
            comparer.ComparisonMethod = PasswordObjectComparer.ComparisonType.Id;

            int pos = passwordObjectList.BinarySearch (new PasswordObject (guid4), comparer);

            Assert.AreEqual (guid4, passwordObjectList[pos].Id);
        }
    }
}
